'use strict';

const Service = require('egg').Service;

class HomeService extends Service {
    //添加
  async put(createtime,title,author,important,readnum,status) {
    return await this.app.mysql.query('insert into list (createtime,title,author,important,readnum,status) values (?,?,?,?,?,?)',[createtime,title,author,important,readnum,status])
  }
  //修改
  async update(createtime,title,author,important,readnum,status,id){
    return await this.app.mysql.query('update list set createtime=?,title=?,author=?,important=?,readnum=?,status=? where id=?',[createtime,title,author,important,readnum,status,id])
  } 
  //删除
  async del(id){
      return await this.app.mysql.query('delete from list where id=?',[id])
  }

  //查询
  async bookslist(start,limit){
      return await this.app.mysql.query(`select * from list limit ${start},${limit}`)
  }
  //查询总条数
  async total(){
      return await this.app.mysql.query('select count(*) from list')
  }
}

module.exports = HomeService;
